<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>

		<!-- 文件上传 -->
		<uni-file-picker v-model="imageValue" fileMediatype="image" mode="grid" @select="select" @progress="progress" @success="success" @fail="fail" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				imageValue: [],
			}
		},
		onLoad() {
			uniCloud.callFunction({
				name: "myFun",
				data: {
					name: "老大",
					age: 26
				}
			}).then(res => {
				console.log('myFun:', res.result)
			})
			this.getDb()
		},
		methods: {
			// 获取上传状态
			select(e) {
				console.log('选择文件：', e)
			},
			// 获取上传进度
			progress(e) {
				console.log('上传进度：', e)
			},

			// 上传成功
			success(e) {
				console.log('上传成功')
			},

			// 上传失败
			fail(e) {
				console.log('上传失败：', e)
			},
			getDb() {
				uniCloud.callFunction({
					name: "dbDemo",
					data: {
						name: "老大",
						age: 26
					}
				}).then(res => {
					console.log('dbDemo:', res.result)
				})
			},
			// 判断按钮是否禁用： some,every
			inDisabled(obj) {
				/*
				for (let k in obj) {
					if (!obj[k]) {
						return true
					}
				}
				*/
				return Object.keys(obj).some((k, v) => {
					return obj[k] == ''
				})
			}

		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
